<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/></head>
<body>
<!--<div style="overflow:scroll; width:100%; height:300px; border:solid 1px #0066CC">
<pre>-->
<?php
// Užkraunam reikiamus modulius!

include_once "variklis/class/Diff/Engine/native.php";
include_once "variklis/class/Diff.php";
include_once "variklis/class/Diff/Renderer.php";
include_once "variklis/class/Diff/Renderer/inline.php";

// define files to compare
$old = (isset($_GET['file']) && file_exists($_GET['file'].".php")?$_GET['file']:'index');
$new = "http://mightmedia.googlecode.com/svn/trunk/".$old;

// perform diff, print output
$diff = &new Text_Diff(file($old.".php"), file($new.".php"));
$renderer = &new Text_Diff_Renderer_inline();

$return = $renderer->render($diff);

//$lines = explode("\n", $return); $lines = count($lines);
echo php_highlight($return);
//echo str_replace("&nbsp;", " ",$return);
?>
<!--</pre>
</div>-->
</body>
</html>
<?php

function php_highlight($string) {
	global $old;
  $Line = explode("\n",$string); $line='';
  
  $search = array('+~!@','+/~!@','-~!@','-/~!@');
  $replace = array('<font style="background-color:green;color:white">','</font>','<font style="background-color:red;color:white;text-decoration:line-through">','</font>');

	for($i=1;$i<count($Line);$i++) {
		
		if (strstr($Line[$i-1], '+~!@') || strstr($Line[$i-1], '-~!@')) { $line .= '&nbsp;<font style="background-color:#FF9900">'.$i.'</font>&nbsp;<br />'; }
		//if () { $line .= "&nbsp;-&nbsp;<br />"; }
		else { $line .= '&nbsp;'.$i.'&nbsp;<br />'; }
	
		//$line .= (stristr($Line[$i-1], '+~!@') === FALSE?'&nbsp;'.$i.'&nbsp;':'&nbsp;<font style="background-color:green;color:white">'.$i.'</font>&nbsp;')."<br>";
		//$line .= (stristr($Line[$i-1], '+~!@') === FALSE?'&nbsp;'.$i.'&nbsp;':'&nbsp;<font style="background-color:green;color:white">'.$i.'</font>&nbsp;')."<br>";
	}
    
  $header='
 <div style="height:400px; overflow: auto;">
  <table border="0" cellpadding="0" cellspacing="0" style="border-style: solid; border-width:1px; border-color: white black black white;white-space: wrap;" class="title">
    <tr>
      <td width="100%" colspan="2"  style="border-style: solid; border-width:1px; border-color: white; background-color: #99ccff; font-family:Arial; color:white; font-weight:bold;">&nbsp;Failas:'.$old.'.php</td>
    </tr>
    <tr>
      <td width="3%" valign="top" style="background-color: #99ccff; border-style: solid; border-width:1px; border-color: white;"><code>'.$line.'</code></td>
      <td width="97%" valign="top" style="background-color: white;">
      <code>
			'.str_replace($search,$replace,highlight_string($string,true)).'
		</code>
		</td>
    </tr>
  </table></div>
';

  return $header;
}
?>
